<template>
  <el-card>
    <!-- 面包屑 -->
    <my-bread level1="数据统计" level2="数据报表"></my-bread>
    <div id="main" style="width: 620px; height: 400px"></div>
  </el-card>
</template>
<script>
var echarts = require("echarts");
export default {
  data() {
    return {};
  },
  mounted() {
    this.useEchart();
  },
  methods: {
    async useEchart() {
      var myChart = echarts.init(document.getElementById("main"));
      // 获取表格数据
      const res = await this.$http.get(`reports/type/1`);
      let option2 = res.data.data;
      // 指定图标的配置项和数据

      var option1 = {
        
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        toolbox:{
            feature:{
                saveAsImage:{}
            }
        },
        grid:{
            left:'3%',
            right:'4%',
            botton:'3%',
            containLabel:true
        },
      };

      myChart.setOption(option1);

      // es6 展开运算符
      let option = { ...option1, ...option2 };

      // 使用刚指定的配置项和数据显示图表
      myChart.setOption(option);
    },
  },
};
</script>

<style>
</style>